/*!
 * @file Sound.cpp
 * @author naoki takeda
 * @version 1.0
 */
#include "StdAfx.h"
#include <windows.h>
#include <xaudio2.h>
#include <mmsystem.h>
#include <dsound.h>
#include "Audio/src/SoundImpl.h"
#include "Audio/src/ManagerImpl.h"

namespace NTEngine {
namespace Audio {

Sound Sound::create( Wave wave ) {
	Sound instance;
	instance.m_Impl = NEW Impl( wave.m_Impl, g_ManagerImpl->XAudio2(), g_ManagerImpl );
	return instance;
}

void Sound::play( int loopCount ) {
	ASSERT( m_Impl && "null ptr." );
	m_Impl->play( loopCount, g_ManagerImpl->operationID() );
}

void Sound::stop() {
	ASSERT( m_Impl && "null ptr." );
	m_Impl->stop();
}

void Sound::setVolume( float v ) {
	ASSERT( m_Impl && "null ptr." );
	ASSERT( ( ( v >= -16777216.F ) && ( v <= 16777216.F ) ) && "" );
	m_Impl->setVolume( v );
}

float Sound::volume() const {
	ASSERT( m_Impl && "null ptr." );
	return m_Impl->volume();
}

void Sound::setFrequencyRatio( float f ) {
	ASSERT( m_Impl && "null ptr." );
	m_Impl->setFrequencyRatio( f );
}

float Sound::frequencyRatio() const {
	ASSERT( m_Impl && "null ptr." );
	return m_Impl->frequencyRatio();
}

bool Sound::isPlaying() const {
	ASSERT( m_Impl && "null ptr." );
	return m_Impl->isPlaying();
}

#define TYPE Sound
#include "NTEngine/Base/Impl/ReferenceTypeTemplate.h"

} // namespace Audio
} // namespace NTEngine
// EOF